package vistas;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Date;
import java.util.Vector;

import javax.swing.JButton;

import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import util.FechaUtil;
import controller.ControllerPrincipal;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class MenuPrincipal extends BaseJFrame {

	private JLabel LabelTitulo;
	private JButton btnAdministrarProveedores;
	private JButton btnAdministrarClientes;
	private JButton btnSolicitarCotizacion;
	private JButton btnGenerarOP;

	// Del controller

	private ControllerPrincipal cp;
	private JButton btnFacturar;

	public static void main(String[] args) {

		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				MenuPrincipal inst = new MenuPrincipal();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}

	public void instaciar() {
		// alta de planes,Alta de servicios.
		// complear

		// quitar para no cargar datos automaticamente
		testear();

	}

	private void testear() {
		// sist.generarDatosDePrueba();

	}

	public MenuPrincipal() {
		super();
		this.cp = ControllerPrincipal.getInstancia();
		// this.instaciar();
		initGUI();
	}

	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			this.setTitle("Menu Principal");
			{
				LabelTitulo = new JLabel();
				getContentPane().add(LabelTitulo);
				LabelTitulo.setText("Sistema de Venta de Rodamientos");
				LabelTitulo.setBounds(48, 6, 256, 16);
			}
			{
				btnAdministrarClientes = new JButton();
				getContentPane().add(btnAdministrarClientes);
				btnAdministrarClientes.setText("Administrar Clientes");
				btnAdministrarClientes.setBounds(30, 93, 250, 28);
				btnAdministrarClientes.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						AdministrarClientes frm = new AdministrarClientes();
						frm.setLocationRelativeTo(null);
						frm.setVisible(true);
					}
				});
			}
			{
				btnFacturar = new JButton();
				getContentPane().add(btnFacturar);
				btnFacturar.setText("Ver Facturas");
				btnFacturar.setBounds(30, 247, 250, 22);
				btnFacturar.addActionListener(new ActionListener() {
					private Date fechaFacturada;

					public void actionPerformed(ActionEvent arg0) {
						FacturasGeneradas frm = new FacturasGeneradas();
						frm.setLocationRelativeTo(null);
						frm.setVisible(true);
						// AdministrarFacturas frm = new AdministrarFacturas();
						// frm.setLocationRelativeTo(null);
						// frm.setVisible(true);

					}
				});
			}
			{
				btnAdministrarProveedores = new JButton();
				getContentPane().add(btnAdministrarProveedores);
				btnAdministrarProveedores.setText("Administrar Proveedores");
				btnAdministrarProveedores.setBounds(30, 47, 250, 28);
				btnAdministrarProveedores.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						AdministrarProveedores frm = new AdministrarProveedores();
						frm.setLocationRelativeTo(null);
						frm.setVisible(true);
					}
				});
			}
			
			{
				btnGenerarOP = new JButton();
				getContentPane().add(btnGenerarOP);
				btnGenerarOP.setText("Generar Orden de Pedido");
				btnGenerarOP.setBounds(30, 197, 250, 28);
				btnGenerarOP.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						GenerarOP frm = new GenerarOP();
						frm.setLocationRelativeTo(null);
						frm.setVisible(true);
					}
				});
			}
			
			{
				btnSolicitarCotizacion = new JButton();
				getContentPane().add(btnSolicitarCotizacion);
				btnSolicitarCotizacion.setText("Solicitar Cotizacion");
				btnSolicitarCotizacion.setBounds(30, 146, 250, 28);
				btnSolicitarCotizacion.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						SolicitarCotizacion frm = new SolicitarCotizacion();
						frm.setLocationRelativeTo(null);
						frm.setVisible(true);
					}
				});
			}
			
			

			pack();
			this.setSize(320, 328);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	protected void _exit() {
		this.dispose();
	}

}
